package com.lanxigua.entity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Message;

import com.lanxigua.utils.ErrorException;

public class User extends Base<User> {
	public String id;
	public String name;
	public String truename;
	public String email;
	public String regdate;
	public String nickname;
	public String signature;
	public String avatar;
	public String gender;
	public String mobile;
	public String telephone;
	public String birthday;
	public String country;
	public String city;
	public String location;
	public String groupcode;
	public String gradecode;
	public String type;
	public String showgender;
	public String showemail;
	public String showbirthday;
	public String msn;
	public String qq;
	public String experience;
	public String score;
	public String award;
	public String checkintimes;
	public String posttimes;
	public String checkindays;
	public String avaragecheckinday;
	
	public User(){
		
	}
	
	public User(JSONObject json) {
		super(json);
	}
	
	public User(JSONArray json){
		for (int i = 0; i < json.length(); i++) {
			try {
				this.list.add(new User(json.getJSONObject(i)));
			} catch (JSONException e) {

			}
		}		
	}
	
	public User(Message message) throws ErrorException{
		super(message);
		if (message.what == 0) {			
			try {
				if (message.obj.getClass() == Class
						.forName("org.json.JSONObject")) {
					return;
				} else if (message.obj.getClass() == Class
						.forName("org.json.JSONArray")) {
					this.list.add(new User((JSONArray)message.obj));
				}
			} catch (ClassNotFoundException e1) {
				
			}
		}else if (message.what == -1){
			throw new ErrorException(message.obj.toString());
		}
	}
}